package com.xyy.saas.payment.util;

import com.xyy.saas.payment.dao.model.BankCodeDictionaries;
import jxl.*;
import jxl.read.biff.BiffException;
import java.io.*;
public class ReadExcel {
    public static void main(String[] args) throws BiffException, IOException {
        //读取表格中第一个sheet表
        getSheet("Sheet1");
        //读取表格中第二个sheet表
//        String[] result2 = getSheet("Sheet1");
//        CompareResult(result1, result2);
//        for (int i = 1; i < result1.length; i++) {
//            if(result1[i] != null) {
//                System.out.println(result1[i]);
//            }
//        }System.out.println("结束");
    }
    /*
     * sh: Excel文件中的sheet
     */
    public static void getSheet(String sh) throws BiffException, IOException {
        //Test1.xls 为你放在java项目下的文件名
        Workbook book = Workbook.getWorkbook(new File("D:\\华通存管支持银行列表.xls"));
        //获得excel文件的sheet表
        Sheet sheet = book.getSheet(sh);
        int rows = sheet.getRows();//行
        int cols = sheet.getColumns();//列
        System.out.println("总列数：" + cols);
        System.out.println("总行数:" + rows);
        System.out.println("----------------------------");
        //循环读取数据
        BankCodeDictionaries bankCodeDictionaries = new BankCodeDictionaries();
        for (int i=1;i<rows;i++){
            Cell cell1=sheet.getCell(0,i);//（列，行）
            Cell cell2=sheet.getCell(1,i);//（列，行）
            System.out.println(cell1.getContents());
            System.out.println(cell2.getContents());
            bankCodeDictionaries.setBankName(cell1.getContents());
            bankCodeDictionaries.setBankCode(cell2.getContents());
        }

    }

}
